package com.wjy.common.exception;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author ybxxszl
 * @desc 统一异常处理
 * @data 2019年4月12日
 */
@RestControllerAdvice
public class ExceptionHandle {

    @ExceptionHandler(value = Exception.class)
    public Map<String, Object> handler(Exception exception) {
        Map<String, Object> map = new HashMap<String, Object>();
        if (exception instanceof BusinessException) {
            map.put("code", "500");
            map.put("message", exception.getMessage());
        } else {
            map.put("code", "500");
            map.put("message", exception.getMessage());
        }
        System.out.println("123");
        return map;
    }

}
